<template>
	<view class="membership">
		<view class="toplogo">
			<image class="" src="@/static/image/vipbg.png" style="width: 550rpx; height: 210rpx;margin-left: 120rpx;">
				<view class="box">
					<image class="" src="@/static/image/vipimg.png" style="width: 178rpx; height: 55rpx;">
						<view class="" style="margin-top: 44rpx;">
							开通VIP，畅享高级功能
						</view>
				</view>
		</view>
		<view class="typebox">
			<view class="outBox">
				<view class="typeitem" :class="{typeitemed : currIndex == 1}" @click="handleCurrIndex(1)">
					<view class="top">
						超值加购
					</view>
					<view class="time">
						{{levelList[0].day}}天
					</view>
					<view class="now">
						<text style="font-size: 30rpx; margin-right: 5rpx;">￥</text>{{levelList[0].price}}
					</view>
					<view class="year">
						￥{{levelList[0].original_price}}
					</view>
				</view>

				<view class="typeitem" :class="{typeitemed : currIndex == 2}" @click="handleCurrIndex(2)">
					<view class="top">
						超值加购
					</view>
					<view class="time">
						{{levelList[1].day}}天
					</view>
					<view class="now">
						<text style="font-size: 30rpx; margin-right: 5rpx;">￥</text>{{levelList[1].price}}
					</view>
					<view class="year">
						￥{{levelList[1].original_price}}
					</view>
				</view>

				<view class="typeitem" :class="{typeitemed : currIndex == 3}" @click="handleCurrIndex(3)">
					<view class="top" style="background-color: #ffffff;border: none;">
					</view>
					<view class="time">
						{{levelList[2].day}}天
					</view>
					<view class="now">
						<text style="font-size: 30rpx; margin-right: 5rpx;">￥</text>{{levelList[2].price}}
					</view>
					<view class="year">
						￥{{levelList[2].original_price}}
					</view>
				</view>
			</view>


			<view class="title">
				<image class="" src="@/static/image/titleicon.png" style="width: 48rpx; height: 40rpx;">
					<image class="" src="@/static/image/iconimg.png"
						style="width: 222rpx; height: 52rpx;margin-left: 10rpx;">
			</view>


			<view class="contentBox">
				<u-parse :content="content"></u-parse>
			</view>

			<view class="descbBox">
				<u-parse :content="Sm"></u-parse>
				<!-- <view class="descitem">
					1、该产品属于数字化产品，不支持七天无理由退货
				</view>
				<view class="descitem">
					2、仅提供房源基本信息内容如图片、视频、位置等，暂不提供租房保障，更多房源详情请与房东了解。
				</view>
				<view class="descitem">
					3、最终解释权归有本公司所有。
				</view>
				<view class="descitem">
					4、如有问题可咨询客服热线。
				</view> -->

			</view>



			<view class="btn" @click="handleBuy">
				立即支付
			</view>

		</view>



	</view>
</template>

<script>
	import {
		buymember,
		getlevel,
		config
	} from "@/api/api.js"
	var graceRichText = require("../../static/richText.js");
	export default {
		data() {
			return {
				bgColor: "transparent",
				currIndex: 1,
				levelList: [],
				buyId: null,
				content: "",
				Sm: "",
			}
		},
		onLoad() {
			this.handleGetlevel()
			this.handleconfig()
		},
		methods: {
			async handleconfig() {
				let res = await config()
				this.content = res.data[5].value
				this.Sm = res.data[6].value
			},
			handleCurrIndex(index) {
				console.log("4444", index)
				this.buyId = this.levelList[index - 1].id
				this.currIndex = index
			},
			async handleGetlevel() {
				let res = await getlevel()
				console.log("会员列表", res)
				this.levelList = res.data
				this.buyId = this.levelList[0].id

			},
			async handleBuy() {
				let res = await buymember({
					id: this.currIndex
				})
				if (res.code == 1000) {
					console.log("支付信息", res)
					uni.requestPayment({
						provider: 'wxpay',
						appId: res.data.appId,
						timeStamp: res.data.timeStamp,
						nonceStr: res.data.nonceStr,
						package: res.data.package,
						signType: res.data.signType,
						paySign: res.data.paySign,
						success(res) {
							console.log("支付成功、、、、、、、、、、、、、、、、")
							uni.redirectTo({
								url: "./index"
							})
						},
						fail(e) {}
					})

				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.descbBox {
		.descitem {
			font-size: 28rpx;
			// color: #F23A00;
		}
	}

	.membership {
		width: 100%;
		min-height: 100%;
		background-color: #ffffff;
	}

	.btn {
		width: 640rpx;
		height: 88rpx;
		background: #F8AD22;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		font-size: 30rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		line-height: 88rpx;
		text-align: center;
		margin: 10rpx auto;
		position: fixed;
		bottom: 100rpx;
		left: 54rpx;
		// margin-top: 100rpx;
	}

	.membership {
		width: 100%;
		// height: 394rpx;
		background: linear-gradient(180deg, #F8AD22 0%, rgba(248, 173, 34, 0.45) 55%, rgba(248, 173, 34, 0) 100%);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		padding-top: 20rpx;
		// background-color: transparent;

		.toplogo {
			width: 690rpx;
			height: 210rpx;
			background: linear-gradient(319deg, #FFC989 0%, #FFD9B4 56%, #FFE9C9 100%);
			box-shadow: inset 0rpx 8rpx 40rpx 0rpx rgba(255, 215, 169, 0.4);
			border-radius: 40rpx 40rpx 0rpx 0rpx;
			margin: 0 auto;
			position: relative;

			.box {
				position: absolute;
				top: 40rpx;
				left: 60rpx;
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #A95C2B;
				line-height: 28rpx;
			}
		}

		.typebox {
			width: 100%;
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 0rpx 0rpx;
			padding: 50rpx 30rpx;
			box-sizing: border-box;
			z-index: 9999;

			.outBox {
				width: 100%;
				display: flex;
				justify-content: space-between;
			}

			.typeitem {
				width: 204rpx;
				height: 268rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 32rpx 0rpx rgba(227, 220, 212, 0.46);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				text-align: center;

				.top {
					width: 204rpx;
					height: 48rpx;
					background: #F8AD22;
					border-radius: 20rpx 20rpx 0rpx 0rpx;
					opacity: 1;
					border: 3rpx solid #F8AD22;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					text-align: center;
					line-height: 48rpx;

				}

				.time {
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 35rpx;
					margin-top: 20rpx;
				}

				.now {
					font-size: 40rpx;
					font-family: DIN-Bold, DIN;
					font-weight: bold;
					color: #F23A00;
					line-height: 45rpx;
					margin-top: 20rpx;
				}

				.year {
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 33rpx;
					margin-top: 22rpx;
					text-decoration-line: line-through;
				}
			}

			.typeitemed {
				border: 3rpx solid #F8AD22;
			}

			.title {
				font-size: 40rpx;
				font-family: YouSheBiaoTiHei-Regular, YouSheBiaoTiHei;
				font-weight: 400;
				line-height: 47rpx;
				color: #F8AD22;
				margin-top: 30rpx;
				display: flex;
			}

			.contentBox {
				width: 670rpx;
				// height: 332rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 32rpx 0rpx rgba(227, 220, 212, 0.46);
				border-radius: 30rpx 30rpx 30rpx 30rpx;
				opacity: 1;
				border: 2rpx solid #F8AD22;
				margin: 20rpx auto;
				padding: 30rpx;
				box-sizing: border-box;
				background: #FEF7E9;

				.top {
					width: 670rpx;
					height: 102rpx;
					border-radius: 30rpx 30rpx 0rpx 0rpx;
					// padding: 0 40rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.topitem {
						font-size: 30rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #EA7509;
						line-height: 35rpx;
						width: 33%;
						text-align: center;
					}
				}

				.content {
					height: 190rpx;
					padding: 30rpx 50rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.contentitem {
						width: 100%;
						display: flex;
						justify-content: space-between;
						align-items: center;

						.left {
							font-size: 28rpx;
							font-family: PingFang SC-Bold, PingFang SC;
							font-weight: bold;
							color: #333333;
							line-height: 33rpx;
							width: 33%;
							text-align: center;
						}

						.bot {
							font-size: 28rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #666666;
							line-height: 33rpx;
							width: 33%;
							text-align: center;
						}

						.right {
							font-size: 28rpx;
							font-family: PingFang SC-Bold, PingFang SC;
							font-weight: bold;
							color: #F8AD22;
							line-height: 33rpx;
							width: 33%;
							text-align: center;
						}
					}
				}
			}
		}
	}
</style>